﻿#region Using

using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using WSMon.Core.Checkers.Mail;
using WSMon.Core.Checkers.Web;
using WSMon.Core.Configuration;
using WSMon.Core.Interfaces;

#endregion

namespace WSMon.Engine
{
    [Serializable]
    public class Hosting
    {
        public Hosting()
        {
            Delay = 3; // min
        }

        [XmlAttribute]
        public string HostingID { get; set; }

        public EmailAccountConfiguration SmtpAccountConfig { get; set; }
        public DnsConfiguration DnsConfig { get; set; }
        public HttpRequestConfiguration HttpRequestConfig { get; set; }
        public SourceCodeConfiguration SourceCodeConfig { get; set; }
        public FtpConfiguration FtpConfig { get; set; }
        public EmailAccountConfiguration Pop3AccountConfig { get; set; }

        public string SslCheckUrl { get; set; }

        public MsSqlConfigration MsSqlConfig { get; set; }

        public int Delay { get; set; }

        public List<IChecker> GetCheckers()
        {
            var checkerList = new List<IChecker>();
            var tmpVerifKey = Guid.NewGuid().ToString();

            if (SmtpAccountConfig != null)
                checkerList.Add(new SmtpChecker(SmtpAccountConfig, tmpVerifKey));

            if (DnsConfig != null)
                checkerList.Add(new DnsChecker(DnsConfig));

            if (HttpRequestConfig != null)
                checkerList.Add(new HttpChecker(HttpRequestConfig));

            if (SourceCodeConfig != null)
                checkerList.Add(new SourceCodeChecker(SourceCodeConfig));

            if (FtpConfig != null)
                checkerList.Add(new FtpChecker(FtpConfig));

            if (Pop3AccountConfig != null)
                checkerList.Add(new Pop3Checker(Pop3AccountConfig, tmpVerifKey));

            if(SslCheckUrl != null)
                checkerList.Add(new SslChecker(SslCheckUrl));

            return checkerList;
        }
    }
}